Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ts: CPI events parsing #2886

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ochaloup
Copy link
Contributor

@ochaloup ochaloup commented Apr 3, 2024

Based on the discussion at #2609 I understood there is no parsing utilities for CPI events for TS libraries.

I would like to kick-off the PR that would add this support under official Anchor TS library.
I'm not sure what would be the best on creating such functionality neither what is the best place to put it.
Maybe the approach is in a wrong direction so it's fine to just close the PR.

/cc @acheroncrypto

Copy link

vercel bot commented Apr 3, 2024

@ochaloup is attempting to deploy a commit to the coral-xyz Team on Vercel.

A member of the Team first needs to authorize it.

@ochaloup ochaloup marked this pull request as draft April 3, 2024 09:48
Copy link
Collaborator

@acheroncrypto acheroncrypto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, something like this would be helpful, but I think we need to improve this further before merging.

ts/packages/anchor/src/coder/borsh/event.ts Outdated Show resolved Hide resolved
ts/packages/anchor/src/coder/borsh/event.ts Outdated Show resolved Hide resolved
ts/packages/anchor/src/utils/events.ts Outdated Show resolved Hide resolved
@ochaloup ochaloup marked this pull request as ready for review April 12, 2024 08:00
@ochaloup
Copy link
Contributor Author

@acheroncrypto thanks for your comments. I'm moving from Draft to a Pull Request state.
I did changes based on your comments with a bit of changing the logic to provide only one decode method for the coders.
I believe it will be easier to grasp to just use decode that does what's needed. But I'm fine to change it back and split to two methods.

With adding the parseCpiEvents into interface I needed to change the default implemenation of the System(like) programs to get the build pass. I created an abstract class. It seemed to me cleaner but we can remove it back as it was.

Copy link
Collaborator

@acheroncrypto acheroncrypto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With adding the parseCpiEvents into interface I needed to change the default implemenation of the System(like) programs to get the build pass. I created an abstract class. It seemed to me cleaner but we can remove it back as it was.

The issue is that those packages are autogenerated, but I think it's fine because I'm planning to change how they work with the new IDL.

}

public parseCpiEvents(
transactionResponse: VersionedTransactionResponse
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great if we could also support TransactionResponse.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I added the TransactionResponse to types.

When autogenerated, how can I run it that I can remove the extended class and make it as generated? I run the ./setup-tests.sh but I haven't found a guideline on development that can help me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants